﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NHibernate;
using NHibernate.Cfg;
using System.Reflection;

namespace QLSV
{
    public partial class frMain : Form
    {
        private ISession _mySession;
        public frMain()
        {
            InitializeComponent();
        }
        static ISessionFactory _mySecsionFactory;
        static ISession OpenSession()
        {
            if (_mySecsionFactory == null)
            {
                var configuration = new Configuration();
                configuration.AddAssembly(Assembly.GetCallingAssembly());

                _mySecsionFactory = configuration.BuildSessionFactory();
            }
            return _mySecsionFactory.OpenSession();
        }
        private void frMain_Load(object sender, EventArgs e)
        {
            using (_mySession = OpenSession())
            {
                ICriteria criteria = _mySession.CreateCriteria<SinhVien>();
                IList<SinhVien> list = criteria.List<SinhVien>();
                //var a = _mySession.CreateQuery("FROM SinhVien s").List<SinhVien>();
                //IList<SinhVien> list = a;
                //dtgv_SinhVien.DataSource = list;
            }
        }
    }
}
